package multiple.thread.copy;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.RandomAccessFile;

public class WriteTo {
	private RandomAccessFile to;

	public WriteTo(String desFile) throws FileNotFoundException {
		this.to = new RandomAccessFile(desFile, "rw");
	}

	// 同步文件写入操作
	synchronized public void write(byte[] buffer, int len, long pos)throws IOException {
		to.seek(pos);
		to.write(buffer, 0, len);
	}

	// 关闭随机文件访问流，释放相关系统资源
	public void close() throws IOException {
		to.close();
	}



}
